﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Configuration;

namespace KBC_Quiz_Show.DBConnect
{
    class Utils
    {
        public SqlConnection getConnection()
        {
            SqlConnection conn = null;
            String strCon = ConfigurationManager.ConnectionStrings["conStr"].ConnectionString;
            try
            {
                conn = new SqlConnection(strCon);
            }
            catch (SqlException ex)
            {
                Console.WriteLine(ex.Message);
            }
            return conn;
        }

        public void freeConn(SqlConnection conn)
        {
            if (conn != null)
            {
                try
                {
                    conn.Close();
                }
                catch (SqlException ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }
    }
}
